package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name = "诸武精通")
@Order(1500)
@Component
public class ZhuWuJingTong extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int abs = Math.abs(first.getBattleInfo().getSpell() - first.getBattleInfo().getAtk());
        int atk;
        if(abs < 50){
            atk = (int) ((first.getBattleInfo().getSpell() + first.getBattleInfo().getAtk())* 0.8);
        }else if(abs < 150){
            atk = (int) ((first.getBattleInfo().getSpell() + first.getBattleInfo().getAtk())* 0.68);
        }else if(abs < 300){
            atk = (int) ((first.getBattleInfo().getSpell() + first.getBattleInfo().getAtk())* 0.55);
        }else {
            atk = (int) ((first.getBattleInfo().getSpell() + first.getBattleInfo().getAtk())* 0.35);
        }

        int def = Math.min(second.getBattleInfo().getRes(),second.getBattleInfo().getDef());

        int dmg = battleHelper.calAtk(atk, def);
        battleHelper.autoAction(this, first, second, content, dmg, "诸武精通");
    }


    @Override
    public String limitDesc() {
        return "无限制";
    }

    @Override
    public String desc() {
        return "诸武精通，你熟知各种武器的用法，无论物理还是法术\n你的物攻与法攻越平衡，造成的伤害越高，最高可造成物法0.8倍率的伤害\n会自适应对方的物抗与法抗，造成更高的伤害";
    }


}
